<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c"
           uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>
<rapid:override name="head">
    <title>考试管理</title>
    <style>
        .btn-pink {
            background-color: #FFDAB9;
        }

    </style>
</rapid:override>
<rapid:override name="content">
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <div>
        <button type="button" onclick="insert()" class="layui-btn layui-btn-lg" style="margin-top:15px;">添加试卷</button>
    </div>
    <script>
        function insert() {
            layer.open({
                type: 2
                , title: false //不显示标题栏
                , closeBtn: false
                , area: ['500px', '500px']
                , shade: 0.8
                , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                , btn: ['取消']
                , btnAlign: 'c'
                , moveType: 1 //拖拽模式，0或者1
                , content: '/admin/online/examAdd'
                , success: function (layero) {
                    // var btn = layero.find('.layui-layer-btn');
                    // btn.find('.layui-layer-btn0').attr({
                    //     href: 'http://www.layui.com/'
                    //     ,target: '_blank'
                    // });
                    layer.close({id: 'LAY_layuipro'})
                }
            });
        }
    </script>
    <table class="layui-table" style="margin-top:15px; background-color: rgba(255,218,185,0.5);
        color: #000;">
        <colgroup>
            <col width="100">
            <col width="120">
            <col width="50">
            <col width="50">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>试卷名</th>
            <th>考试时间</th>
            <th>考试持续时间</th>
            <th>试卷总分</th>
            <th>是否已批阅</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${paging.dataList}" var="exam">
            <tr onclick="examDetail(${exam.examId})">
                <td>${exam.examName}</td>
                <td>${exam.formateTime(exam.examStartDate)}</td>
                <td>${exam.examLastTime}</td>
                <td>${exam.score}</td>
                <td>${exam.reading}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div style="text-align:center; margin-top:10px; margin-left:-100px;" >
        <c:if test="${paging.totalPage >=0}">
            <p style=" color: black; font-size:16px; margin-bottom:10px;">当前第 ${paging.currentPage } 页/共  ${paging.totalPage} 页</p>
            <c:choose>
                <c:when test="${paging.totalPage==0}">
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(1)">首页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage-1})">上一页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage+1})">下一页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.totalPage})">末页</button>
                </c:when>
                <c:when test="${paging.currentPage==1 && paging.totalPage==1}">
                    <button class="layui-btn" onclick="goPage(1)">首页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage-1})">上一页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage+1})">下一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.totalPage})">末页</button>
                </c:when>
                <c:when test="${paging.currentPage==1 && paging.totalPage>1}">
                    <button class="layui-btn" onclick="goPage(1)">首页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage-1})">上一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.currentPage+1})">下一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.totalPage})">末页</button>
                </c:when>
                <c:when test="${paging.currentPage>1 && paging.currentPage<paging.totalPage}">
                    <button class="layui-btn" onclick="goPage(1)">首页</button>
                    <button class="layui-btn" onclick="goPage(${paging.currentPage-1})">上一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.currentPage+1})">下一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.totalPage})">末页</button>
                </c:when>
                <c:when test="${paging.currentPage>1 && paging.currentPage==paging.totalPage}">
                    <button class="layui-btn" onclick="goPage(1)">首页</button>
                    <button class="layui-btn" onclick="goPage(${paging.currentPage-1})">上一页</button>
                    <button class="layui-btn layui-btn-disabled" onclick="goPage(${paging.currentPage+1})">下一页</button>
                    <button class="layui-btn" onclick="goPage(${paging.totalPage})">末页</button>
                </c:when>
            </c:choose>
        </c:if>
    </div>
    <script>
        function examDetail(examId) {
            window.location.href="<%=basePath%>admin/online/examDetail?examId="+examId + "&page=1";

        }
        function goPage(page){
            window.location.href="<%=basePath%>admin/online/exam?page="+page;
        }

        function delete_fun(classId) {
            var r=confirm("确认删除吗？")
            if (r==true)
            {
                window.location.href="<%=basePath%>teacher/deleteCourse?courseid="+classId;
            }
            else
            {
                return;
            }
        }
        function detail_fun(classId) {
            window.location.href="<%=basePath%>teacher/detailCourse?courseid="+classId+"&page="+1;
        }
    </script>
</rapid:override>
<%@ include file="../base.jsp" %>
